﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FineAdmin.Common;
using FineAdmin.IService;
using FineAdmin.Model;
using FineAdmin.Web.Controllers;
using HuiJI.Tools.TBK;
using Top.Api;
using Top.Api.Request;

namespace FineAdmin.Web.Areas.Shop.Controllers
{
    public class TBKToolsController : BaseController
    {
        // GET: Shop/TBKTools
        public IItemsService ItemsService { get; set; }
        public IItemsDetailService ItemsDetailService { get; set; }

        public override ActionResult Index(int? id)
        {
            var ActivityItem = ItemsService.GetByWhere("where EnCode = 'Activity' ").First();
            ViewBag.ActivityList = ItemsDetailService.GetByWhere("where ItemId = '" + ActivityItem.Id + "'").ToList();
            base.Index(id);
            return View();
        }
        /// <summary>
        /// 
        /// </summary>
        public ActionResult Activity_Info_Get(string activity_material_id)
        {
            var adz = AdZoneAll().Where(m => m.IsDefault == true).FirstOrDefault();
            string Api_Url = SystemParameterAll().Find(m => m.Code == "TBK_API").SPValue;
            TBKTools tbk_tools = new TBKTools(Api_Url);
            var ret = tbk_tools.ActivityInfoGet(adz.TBK_AppKey, adz.TBK_AppSecret, (long)adz.TBK_AdzoneId, activity_material_id);
            return Json(ret, JsonRequestBehavior.DenyGet);
        }
    }
}